<?php
namespace Home\Controller;
class NewsController extends CommonController {

    public function lists() {
        $Dao = M('article_cat');
        $lists = $Dao->where("is_system=0")->order("ord ASC")->select();
        $Dao2 = M('article');
        foreach ($lists as $k => $v) {
            $lists[$k]['sub'] = $Dao2->where("pid = " . $v['id'] . "")->select();
        }
        $id = I("get.id", 0, 'int') ? I("get.id", 0, 'int') : $lists[0]['id'];
        $detail = $Dao2->field("content,title")->where("id = " . $id . "")->find();
        $this->assign("detail", $detail);
        $this->assign("lists", $lists);
        
        $this->display();
    }

    public function join() {
        $Dao = M('article_cat');
        $lists = $Dao->where("is_system=0")->order("ord ASC")->select();
        $Dao2 = M('article');
        foreach ($lists as $k => $v) {
            $lists[$k]['sub'] = $Dao2->where("pid = " . $v['id'] . "")->select();
        }
       
        $this->assign("lists", $lists);
        
        $this->assign("ctitle", '餐厅加盟');
        $this->display();
    }
    public function join_post() {
        $data['name'] = I("post.name");
        $data['contactor'] = I("post.contactor");
        $data['phone'] = I("post.phone");
        $data['email'] = I("post.email");
        $data['addr'] = I("post.addr");
        $data['qq'] = I("post.qq");
        $data['uid'] = session("userid");
        $data['addtime'] = time();
        $Dao = M("shop_apply");
       $lastid =  $Dao->add($data);
//       echo $Dao->getlastsql();exit;
       if($lastid>0){
           $this->success('成功提交申请餐厅加盟，请等待客服和您联系！');
       }else{
            $this->error('提交失败，请联系管理员！');
       }
    }

}